#ifndef OCK_MEMORY_BRIDGE_ADAPTER_STR_UTILS_H
#define OCK_MEMORY_BRIDGE_ADAPTER_STR_UTILS_H
#include <sstream>
#include <vector>
#include <string>
#include "ock/utils/OstreamUtils.h"
namespace ock {
namespace utils {

void Trim(::std::string &strSrc, const ::std::string &strTotrim);

template <typename T>
std::string ToString(const T &data) 
{
    std::ostringstream osStr;
    osStr << data;
    return osStr.str();
}
namespace detail {
template <typename T>
bool FromString(T &result, const std::string &data) 
{
    try {
        std::istringstream is;
        is >> result;
        return !is.fail() && !is.bad() && is.eof();
    } catch (...) {
        return false;
    }
}

} // namespace detail

template <typename T>
bool FromString(T &result, const std::string &data) 
{
    return detail::FromString(result, data);
}
bool FromStringEx(uint8_t &result, const std::string &data)
bool FromStringEx(uint16_t &result, const std::string &data) 
bool FromStringEx(uint32_t &result, const std::string &data) 
bool FromStringEx(uint64_t &result, const std::string &data) 
bool FromStringEx(bool &result, const std::string &data) 
bool FromStringEx(int8_t &result, const std::string &data)
bool FromStringEx(int16_t &result, const std::string &data) 
bool FromStringEx(int32_t &result, const std::string &data) 
bool FromStringEx(int64_t &result, const std::string &data) 

template <>
inline bool FromString<uint8_t>(uint8_t &result, const std::string &data) 
{
    return FromStringEx(result, data);
}

template <>
inline bool FromString<uint16_t>(uint16_t &result, const std::string &data) 
{
    return FromStringEx(result, data);
}

template <>
inline bool FromString<uint32_t>(uint32_t &result, const std::string &data) 
{
    return FromStringEx(result, data);
}

template <>
inline bool FromString<uint64_t>(uint64_t &result, const std::string &data) 
{
    return FromStringEx(result, data);
}

template <>
inline bool FromString<bool>(bool &result, const std::string &data) 
{
    return FromStringEx(result, data);
}

template <>
inline bool FromString<int8_t>(int8_t &result, const std::string &data) 
{
    return FromStringEx(result, data);
}

template <>
inline bool FromString<int16_t>(int16_t &result, const std::string &data) 
{
    return FromStringEx(result, data);
}

template <>
inline bool FromString<int32_t>(int32_t &result, const std::string &data) 
{
    return FromStringEx(result, data);
}

template <>
inline bool FromString<int64_t>(int64_t &result, const std::string &data) 
{
    return FromStringEx(result, data);
}

void Spilt(const ::std::string &text, const ::std::string &delimiter, ::std::vector< ::std::string> &tokens);
std::string ToUpper(const std::string &data);

}
}
#endif